package com.wgw.first.utils;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

/**
 * @author Admin
 * @version $Rev$
 * @des ${TODO}
 * @updateAuthor $Author$
 * @updateDes ${TODO}
 */
public class StreamUtils {

    public static String readStream(InputStream is,int i){
        try {

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int len = 0;
            while((len = is.read(buffer))!=-1){
                baos.write(buffer,0,len);
            }
            is.close();
            String result = baos.toString();
            if(i == 1){
                return baos.toString("gbk");

            }
            return result;

        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }



}
